package Homework_stream724;

import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

public class lianxi {
    public static void main(String[] args) {  
        List<String> strings = Arrays.asList("apple", "banana", "cherry", "date", "elderberry");  
  
        Map<Integer, List<String>> byLength = strings.stream()  
            .collect(Collectors.groupingBy(String::length));  
  
        byLength.forEach((length, words) -> System.out.println(length + ": " + words));  
    }  
}
